package java_1_12.book_management.operation.impl;

import java_1_12.book_management.book.Book;
import java_1_12.book_management.book.BookList;
import java_1_12.book_management.operation.IOperation;

//增加操作-添加书籍
public class AddOperation implements IOperation {

    @Override
    public void work(BookList bookList) {
        System.out.println("您现在进行的是添加书籍操作");
        System.out.println("请输入书籍名称");
        String booksName=scanner.next();
        //细节：这里需要判断书籍是否存在，有就不用加
        if(bookList.contains(booksName)){
            System.out.println("书本已存在，无需重复添加");
            return;
        }
        System.out.println("请输入作者");
        String author=scanner.next();
        System.out.println("请输入价格");
        double price=scanner.nextDouble();
        System.out.println("请书籍输入类别");
        String type=scanner.next();
        Book book=new Book(booksName,author,price,type);
        bookList.add(book);
        System.out.println("添加书籍成功");
    }
}
